package com.cardbaobao.cardbabyclient.api;

import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.cardbaobao.cardbabyclient.base.Constant;
import com.cardbaobao.cardbabyclient.utils.URLUtil;

import java.util.HashMap;
import java.util.Map;

import rx.Observable;

/**
 * Created by Jiangzx on 2017/8/8 10:48.
 */

public class Api {

    public static Observable<String> getUserInfo(String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("ID", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.USER_INFO, params);
    }

    //学信网授权前置步骤
    public static Observable<String> preChsiAuth() {
        return RequestUtils.postEncryptDecrypt(URLUtil.PRE_CHSI_AUTH, null);
    }

    //学信网授权
    public static Observable<String> chsiAuth(Map<String, Object> params) {
        return RequestUtils.postEncryptDecrypt(URLUtil.CHSI_AUTH, params);
    }

    //登录
    public static Observable<String> login(String account, String pwd) {
        Map<String, Object> params = new HashMap<>();
        params.put("Account", account);
        params.put("PassWord", pwd);
        return RequestUtils.postEncryptDecrypt(URLUtil.LOGIN, params);
    }

    //获取用户身份信息
    public static Observable<String> getMemberInfo(int userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("ID", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.MEMBER_INFO, params);
    }

    //获取社保、公积金城市列表
    public static Observable<String> getAuthCityList(String channel) {
        Map<String, Object> params = new HashMap<>();
        params.put("channel_type", channel);
        return RequestUtils.postEncryptDecrypt(URLUtil.AUTH_CITY_LIST, params);
    }

    //获取[社保、公积金]登录要素
    public static Observable<String> getLoginElements(String channel, String cityCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("channel_type", channel);
        params.put("channel_code", cityCode);
        return RequestUtils.postEncryptDecrypt(URLUtil.LOGIN_ELEMENTS, params);
    }

    //创建[社保、公积金授权/查询]爬取任务
    public static Observable<String> createTask(Map<String, Object> params) {
        return RequestUtils.postEncryptDecrypt(URLUtil.CREATE_TASK, params);
    }

    //任务爬取
    public static Observable<String> crawling(Map<String, Object> params) {
        return RequestUtils.postEncryptDecrypt(URLUtil.TASK_CRAWLING, params);
    }

    //带验证码的任务爬取
    public static Observable<String> crawling(int userId,
                                              String authCode,
                                              String taskId,
                                              String channel_type,
                                              boolean auth) {
        Map<String, Object> params = new HashMap<>();
        params.put("user_id", userId);
        params.put("task_id", taskId);
        params.put("auth_code", authCode);
        params.put("channel_type", channel_type);
        if (!auth) {
            //非授权，也就是查询的时候，传个标记
            params.put("task_flag", 1);
        }
        return RequestUtils.postEncryptDecrypt(URLUtil.TASK_CRAWLING_WITH_AUTH_CODE, params);
    }

    //社保、公积金爬取刷新验证码
    public static Observable<String> refreshAuthCode(String taskId) {
        Map<String, Object> params = new HashMap<>();
        params.put("task_id", taskId);
        return RequestUtils.postEncryptDecrypt(URLUtil.REFRESH_AUTH_CODE, params);
    }

    //更新用户昵称
    public static Observable<String> updateUserNickName(String userId, String nickName) {
        Map<String, Object> params = new HashMap<>();
        params.put("ID", userId);
        params.put("UserName", nickName);
        return RequestUtils.postEncryptDecrypt(URLUtil.UPDATE_USER_NICK_NAME, params);
    }

    //更新用户头像
    public static Observable<String> updateUserAvatar(String userId, String fileAbsolutePath) {
        Map<String, Object> params = new HashMap<>();
        params.put("ID", userId);
        return RequestUtils.postFile(URLUtil.UPDATE_USER_AVATAR, fileAbsolutePath, params);
    }

    //获取banner数据
    public static Observable<String> getBannerData(String code) {
        Map<String, Object> params = new HashMap<>();
        params.put("banner_code", code);
        return RequestUtils.postEncryptDecrypt(URLUtil.BANNER_PIC, params);
    }

    //获取办卡进度银行列表
    public static Observable<String> getCardProgressBankList() {
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_CARD_BANK_LIST, null);
    }

    //获取所有的[贷款申请]城市
    public static Observable<String> getFullCityList() {
        return RequestUtils.postEncryptDecrypt(URLUtil.FULL_CITY_LIST, null);
    }

    //获取申请信用卡城市列表
    public static Observable<String> getApplyCreditCardCityList() {
        return RequestUtils.postEncryptDecrypt(URLUtil.APPLY_CREDIT_CARD_CITY_LIST, null);
    }

    //获取办卡攻略数据
    public static Observable<String> getCreditCardRaiders() {
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_CARD_RAIDERS_INDEX, null);
    }

    //获取办卡攻略顶部label
    public static Observable<String> getRaidersLabelList() {
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_CARD_RAIDERS_TOP_LABLE, null);
    }

    //获取带过滤条件的攻略列表数据
    public static Observable<String> getRaidersFilterData(int page, String code) {
        Map<String, Object> params = new HashMap<>();
        if (page > 0) {
            params.put("pageNum", String.valueOf(page));
        }
        params.put("parent_code", code);
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_CARD_RAIDERS, params);
    }

    //获取信用卡详情数据
    public static Observable<String> getCreditCardDetail(String cardId, String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("cardID", cardId);
        params.put("memberID", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_CARD_DETAIL_TOP, params);
    }

    //获取信用卡详情页猜你喜欢
    public static Observable<String> getYouLikeCreditCards(String cardId, String cityId) {
        Map<String, Object> params = new HashMap<>();
        params.put("site", "3G");
        params.put("cityID", cityId);
        params.put("cardID", cardId);
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_CARD_DETAIL_GUESS_LIKE, params);
    }

    //获取贷款详情数据
    public static Observable<String> getLoanDetail(String loanId, String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("ID", loanId);
        if (!TextUtils.isEmpty(userId)) {
            params.put("MemberID", userId);
        }
        return RequestUtils.postEncryptDecrypt(URLUtil.LOAN_DETAIL, params);
    }

    //信用变钱首页接口
    public static Observable<String> getCreditToCashIndex(String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("ID", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_TO_CASH_INDEX, params);
    }

    //获取授权状态
    public static Observable<String> getAuthStatus(int userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("user_id", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.AUTH_STATUS, params);
    }

    //获取头部公共数据
    public static Observable<String> getCommonHeader(String code) {
        Map<String, Object> params = new HashMap<>();
        params.put("code", code);
        return RequestUtils.postEncryptDecrypt(URLUtil.HEAD_COMMON, params);
    }

    //获取红包数据
    public static Observable<String> getRedEnvelopes(String page) {
        Map<String, Object> params = new HashMap<>();
        params.put("pageNum", page);
        return RequestUtils.postEncryptDecrypt(URLUtil.DAILY_RED_ENVELOPES, params);
    }

    //提交点击过的红包id
    public static Observable<String> commitRedEnvelopsRecord(String ids) {
        Map<String, Object> params = new HashMap<>();
        params.put("ids", ids);
        return RequestUtils.postEncryptDecrypt(URLUtil.COMMIT_RED_ENVELOPES_RECORD, params);
    }

    //反馈
    public static Observable<String> feedback(String content, String contact, String nickName) {
        Map<String, Object> params = new HashMap<>();
        params.put("Content", content);
        params.put("Contact", contact);
        if (!TextUtils.isEmpty(nickName)) {
            params.put("Author", nickName);
        }
        return RequestUtils.postEncryptDecrypt(URLUtil.FEEDBACK, params);
    }

    //重置密码
    public static Observable<String> resetPwd(String account, String newPwd) {
        Map<String, Object> params = new HashMap<>();
        params.put("Mobile", account);
        params.put("NewPassWord", newPwd);
        return RequestUtils.postEncryptDecrypt(URLUtil.RESET_PASSWORD, params);
    }

    //检查手机号是否注册
    public static Observable<String> checkPhoneRegistered(String account) {
        Map<String, Object> params = new HashMap<>();
        params.put("Mobile", account);
        return RequestUtils.postEncryptDecrypt(URLUtil.CHECK_PHONE_REGISTERED, params);
    }

    /**
     * 发送短信
     * @param phone 手机号码
     * @param type 短信类型
     * @param sms 验证码
     * @param fromPage 来源页面
     */
    public static Observable<String> sendSms(String phone, String type, String sms,String fromPage) {
        Map<String, Object> params = new HashMap<>();
        params.put("type", type);
        params.put("mobile", phone);
        params.put("mobilecode", sms);
        params.put("operate_type",fromPage);
        return RequestUtils.postEncryptDecrypt(URLUtil.SEND_SMS, params);
    }

    //获取热门活动
    public static Observable<String> getHotEvents(String page) {
        Map<String, Object> params = new HashMap<>();
        params.put("pageNum", page);
        return RequestUtils.postEncryptDecrypt(URLUtil.HOT_ACTIVITIES, params);
    }

    //获取贷款过滤条件
    public static Observable<String> getLoanPopFilter() {
        return RequestUtils.postEncryptDecrypt(URLUtil.LOAN_POP_DATA, null);
    }

    //获取贷款过滤数据
    public static Observable<String> getLoanFilterData(Map<String, Object> params) {
        return RequestUtils.postEncryptDecrypt(URLUtil.LOAN_LIST_DATA, params);
    }

    //获取消息列表
    public static Observable<String> getMessageList(String page) {
        Map<String, Object> params = new HashMap<>();
        params.put("pageNum", page);
        return RequestUtils.postEncryptDecrypt(URLUtil.MY_MESSAGE_LIST, params);
    }

    //注册
    public static Observable<String> register(String phone,
                                              String pwd,
                                              String platformType,
                                              String channelType) {
        Map<String, Object> params = new HashMap<>();
        params.put("Mobile", phone);
        params.put("PassWord", pwd);
        params.put("platform_type",platformType);
        params.put("channel_type",channelType);
        params.put("os_type","OXT0101");//OXT0101 Android,OXT0102 IOS
        return RequestUtils.postEncryptDecrypt(URLUtil.REGISTER, params);
    }

    //获取新手办卡数据
    public static Observable<String> getNoviceCards(String page) {
        Map<String, Object> params = new HashMap<>();
        params.put("pageNumber", page);
        return RequestUtils.postEncryptDecrypt(URLUtil.NOVICE_CREDIT_CARD, params);
    }

    //运营商授权创建任务
    public static Observable<String> yysCreateTask(Map<String, Object> params) {
        RequestUtils.TimeOutBuilder timeOut =
                new RequestUtils.TimeOutBuilder(RequestUtils.READ_TIME_OUT_LONG,
                        RequestUtils.READ_TIME_OUT_LONG, RequestUtils.READ_TIME_OUT_LONG);
        return RequestUtils.postEncryptDecrypt(URLUtil.YYS_CREATE_TASK, params, timeOut);
    }

    //运营商授权
    public static Observable<String> yysAuth(String taskId, String smsCode, String imageCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("task_id", taskId);
        if (!TextUtils.isEmpty(smsCode)) {
            params.put("sms_code", smsCode);
        }
        if (!TextUtils.isEmpty(imageCode)) {
            params.put("auth_code", imageCode);
        }
        RequestUtils.TimeOutBuilder timeOut =
                new RequestUtils.TimeOutBuilder(RequestUtils.READ_TIME_OUT_LONG,
                        RequestUtils.READ_TIME_OUT_LONG, RequestUtils.READ_TIME_OUT_LONG);
        return RequestUtils.postEncryptDecrypt(URLUtil.YYS_AUTH, params, timeOut);
    }

    //运营商授权刷新验证码
    public static Observable<String> yysRefreshAuthCode(String taskId) {
        Map<String, Object> params = new HashMap<>();
        params.put("task_id", taskId);
        return RequestUtils.postEncryptDecrypt(URLUtil.YYS_REFRESH_AUTH_CODE, params);
    }

    //修改个人信息
    public static Observable<String> updatePersonInfo(Map<String, Object> params) {
        return RequestUtils.postEncryptDecrypt(URLUtil.UPDATE_PERSON_INFO, params);
    }

    //获取个人公积金基础部分
    public static Observable<String> getPersonProvidentFundBase(int userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("user_id", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.PROVIDENT_FUND_BASE, params);
    }

    //获取个人公积金详情
    public static Observable<String> getPersonProvidentFundDetail(String taskId, int page, int pageSize) {
        Map<String, Object> params = new HashMap<>();
        params.put("task_id", taskId);
        params.put("page", page);
        params.put("pageSize", pageSize);
        return RequestUtils.postEncryptDecrypt(URLUtil.PROVIDENT_FUND_DETAIL, params);
    }

    //实名认证
    public static Observable<String> realNameIdentify(String realName, String idNo, String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("name", realName);
        params.put("id_number", idNo);
        params.put("MemberID", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.REAL_NAME_IDENTIFY, params);
    }

    //查询社保记录
    public static Observable<String> querySocialSecurityResult(int userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("user_id", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.SOCIAL_SECURITY_RECORD, params);
    }

    //急速办卡标签页
    public static Observable<String> speedCardLabel() {
        return RequestUtils.postEncryptDecrypt(URLUtil.SPEED_CARD_TAG, null);
    }

    //急速办卡列表数据
    public static Observable<String> speedCardData(Map<String, Object> params) {
        return RequestUtils.postEncryptDecrypt(URLUtil.SPEED_CARD, params);
    }

    //急速贷款列表数据
    public static Observable<String> speedLoanData(Map<String, Object> params) {
        return RequestUtils.postEncryptDecrypt(URLUtil.SPEED_OR_PRODUCT, params);
    }

    //修改密码
    public static Observable<String> modifyPassword(String userId, String oldPwd, String newPwd) {
        Map<String, Object> params = new HashMap<>();
        params.put("ID", userId);
        params.put("OldPassWord", oldPwd);
        params.put("NewPassWord", newPwd);
        return RequestUtils.postEncryptDecrypt(URLUtil.MODIFY_PASSWORD, params);
    }

    //信用卡申请记录
    public static Observable<String> creditCardApplyRecord(String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("memberID", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_CARD_APPLY_RECORD, params);
    }

    //贷款申请记录
    public static Observable<String> loanApplyRecord(String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("MemberID", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.LOANS_APPLY_RECORD, params);
    }

    //收藏的信用卡
    public static Observable<String> collectedCreditCard(String type, String userId,
                                                         String page, String pageSize) {
        Map<String, Object> params = new HashMap<>();
        params.put("TypeID", type);
        params.put("MemberID", userId);
        params.put("pageSize", pageSize);
        params.put("pageIndex", page);
        return RequestUtils.postEncryptDecrypt(URLUtil.MY_COLLECT_CARD, params);
    }

    //收藏的贷款
    public static Observable<String> collectedLoan(String type, String userId,
                                                   String page, String pageSize) {
        Map<String, Object> params = new HashMap<>();
        params.put("TypeID", type);
        params.put("MemberID", userId);
        params.put("pageSize", pageSize);
        params.put("pageIndex", page);
        return RequestUtils.postEncryptDecrypt(URLUtil.MY_COLLECT_LOAN, params);
    }

    //获取信用卡首页数据[热门推荐、合作银行、品质生活、人气排行、高端特权]
    public static Observable<String> getCreditCardIndexData() {
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_CARD_INDEX, null);
    }

    //社保、公积金查询结果
    public static Observable<String> socialFundQueryResult(int userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("user_id", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.S_F_QUERY_RESULT, params);
    }

    //获取首页列表数据
    public static Observable<String> getIndexLayoutData() {
        return RequestUtils.postEncryptDecrypt(URLUtil.HOME_TAB, null);
    }

    //获取贷款首页授权类型
    public static Observable<String> getLoanIndexAuthType() {
        return RequestUtils.postEncryptDecrypt(URLUtil.LOAN_INDEX, null);
    }

    //app检查更新
    public static Observable<String> checkAppUpdate(String versionCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("version", versionCode);
        return RequestUtils.postEncryptDecrypt(URLUtil.CHECK_UPDATE, params);
    }

    //获取城市信息
    public static Observable<String> queryCityInfo(String cityName) {
        Map<String, Object> params = new HashMap<>();
        params.put("cityName", cityName);
        return RequestUtils.postEncryptDecrypt(URLUtil.QUERY_CITY_INFO, params);
    }

    //获取附近银行网点
    public static Observable<String> nearbyBankOutlets(String page,
                                                       String cityName,
                                                       String longitude,
                                                       String latitude) {
        Map<String, Object> params = new HashMap<>();
        params.put("pageIndex", page);
        params.put("pageSize", String.valueOf(Constant.SIZE));
        params.put("core", "6");//搜索银行网点
        params.put("distance", "5000");
        params.put("keyword", cityName);
        if (!TextUtils.isEmpty(longitude)) {
            params.put("longitude", longitude);
        }
        if (!TextUtils.isEmpty(latitude)) {
            params.put("latitude", latitude);
        }
        return RequestUtils.postEncryptDecrypt(URLUtil.BANK_NET_POT, params);
    }

    //银行电话列表
    public static Observable<String> bankTelList() {
        return RequestUtils.postEncryptDecrypt(URLUtil.BANK_TLE_LIST, null);
    }

    //收藏信用卡/贷款
    public static Observable<String> collect(String userId, String productId, String type) {
        Map<String, Object> params = new HashMap<>();
        params.put("MemberID", userId);
        params.put("SID", productId);
        params.put("TypeID", type);
        return RequestUtils.postEncryptDecrypt(URLUtil.COLLECT_PRODUCT, params);
    }

    //取消收藏信用卡/贷款
    public static Observable<String> unCollect(String userId, String productId, String type) {
        Map<String, Object> params = new HashMap<>();
        params.put("MemberID", userId);
        params.put("SID", productId);
        params.put("TypeID", type);
        return RequestUtils.postEncryptDecrypt(URLUtil.UN_COLLECT_PRODUCT, params);
    }

    //判断用户是否绑储蓄卡
    public static Observable<String> checkBindCard(String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.CHECK_BIND_CARD, params);
    }

    //获取银行列表
    public static Observable<String> getBankList(int cardType) {
        Map<String, Object> params = new HashMap<>();
        params.put("type", cardType);
        return RequestUtils.postEncryptDecrypt(URLUtil.BANK_LIST_BY_TYPE, params);
    }

    //查询卡bin
    public static Observable<String> queryCardBin(String cardNumber) {
        Map<String, Object> params = new HashMap<>();
        params.put("card_no", cardNumber);
        return RequestUtils.postEncryptDecrypt(URLUtil.QUERY_CARD_BIN, params);
    }

    //绑定储蓄卡
    public static Observable<String> bindDebitCard(@NonNull Map<String, String> strParams) {
        Map<String, Object> params = new HashMap<>();
        for (Map.Entry<String, String> entry : strParams.entrySet()) {
            params.put(entry.getKey(), entry.getValue());
        }
        return RequestUtils.postEncryptDecrypt(URLUtil.BIND_DEBIT_CARD, params);
    }

    //获取快捷收款 收款费率
    public static Observable<String> getQuickDebitFeeRate() {
        return RequestUtils.postEncryptDecrypt(URLUtil.QUICK_DEBIT_FEE_RATE, null);
    }

    //获取二维码收款 收款费率
    public static Observable<String> getQrCodeDebitFeeRate() {
        return RequestUtils.postEncryptDecrypt(URLUtil.QR_CODE_DEBIT_FEE_RATE, null);
    }

    //判断有没有绑信用卡
    public static Observable<String> hasBindCreditCard(String salesId, String amount) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", salesId);
        params.put("amount", amount);
        return RequestUtils.postEncryptDecrypt(URLUtil.CHECK_BIND_CREDIT_CARD, params);
    }

    //绑定信用卡
    public static Observable<String> bindCreditCard(@NonNull Map<String, String> strParams) {
        Map<String, Object> params = new HashMap<>();
        for (Map.Entry<String, String> entry : strParams.entrySet()) {
            params.put(entry.getKey(), entry.getValue());
        }
        return RequestUtils.postEncryptDecrypt(URLUtil.BIND_CREDIT_CARD, params);
    }

    //获取信用卡列表
    public static Observable<String> getUserBindCards(String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.USER_BANK_CARD_LIST, params);
    }

    /**
     * 快捷收款下单
     *
     * @param userId      用户id
     * @param inputAmount 应付金额
     * @param spaceAmount 到账金额
     * @param cardId      信用卡id
     * @return
     */
    public static Observable<String> quickDebitOrder(String userId, String inputAmount,
                                                     String spaceAmount, String cardId) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", userId);
        params.put("payable_amount", inputAmount);
        params.put("receive_amount", spaceAmount);
        params.put("credit_card_id", cardId);
        return RequestUtils.postEncryptDecrypt(URLUtil.QUICK_DEBIT_COMMIT_ORDER, params);
    }

    //快捷收款发送短信
    public static Observable<String> quickDebitSms(String userId, String orderNumber) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", userId);
        params.put("order_no", orderNumber);
        return RequestUtils.postEncryptDecrypt(URLUtil.QUICK_DEBIT_SMS, params);
    }

    //快捷收款确认接口
    public static Observable<String> quickDebitEnsure(String userId, String orderNo, String verifyCode) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", userId);
        params.put("order_no", orderNo);
        params.put("sms_code", verifyCode);
        return RequestUtils.postEncryptDecrypt(URLUtil.QUICK_DEBIT_ENSURE, params);
    }

    //交易记录详情[订单详情]
    public static Observable<String> getTransactionDetail(String userId, String orderNo) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", userId);
        params.put("order_no", orderNo);
        return RequestUtils.postEncryptDecrypt(URLUtil.TRANSACTION_DETAIL, params);
    }

    /**
     * 二维码下单
     *
     * @param userId      用户id
     * @param amount      应付金额
     * @param channelType 渠道
     * @param fee         手续费
     * @param arrival     到账金额
     * @return
     */
    public static Observable<String> qrCodeDebitOrder(String userId,
                                                      String amount,
                                                      String channelType,
                                                      String fee,
                                                      String arrival) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", userId);
        params.put("amount", amount);
        params.put("rate_channel_type", channelType);
        params.put("fee", fee);
        params.put("receive_amount", arrival);
        return RequestUtils.postEncryptDecrypt(URLUtil.QR_CODE_DEBIT_ORDER, params);
    }

    //交易记录
    public static Observable<String> getTransactionRecords(int type, int userId, int page) {
        Map<String, Object> params = new HashMap<>();
        params.put("type", type);
        params.put("member_id", userId);
        params.put("pageNum", page);
        return RequestUtils.postEncryptDecrypt(URLUtil.MINE_TRANSACTION_RECORDS, params);
    }

    //解绑储蓄卡
    public static Observable<String> unBindDebitCard(String cardNumber, String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("debit_card_no", cardNumber);
        params.put("member_id", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.UN_BIND_DEBIT_CARD, params);
    }

    //解绑信用卡
    public static Observable<String> unBindCreditCard(String cardNumber, String userId) {
        Map<String, Object> params = new HashMap<>();
        params.put("credit_card_no", cardNumber);
        params.put("member_id", userId);
        return RequestUtils.postEncryptDecrypt(URLUtil.UN_BIND_CREDIT_CARD, params);
    }

    //信用卡提额列表
    public static Observable<String> upperQuotaList() {
        return RequestUtils.postEncryptDecrypt(URLUtil.UPPER_QUOTA_LIST, null);
    }

    //信用卡还款卡列表
    public static Observable<String> getCreditData(String member_id) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", member_id);
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_REPAYMENT, params);
    }

    //信用卡还款记录列表
    public static Observable<String> getCreditRecordData(String member_id, String credit_card_no) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", member_id);
        if (!credit_card_no.equals("")) {
            params.put("credit_card_no", credit_card_no);
        }
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_REPAYMENT_RECORD, params);
    }

    //信用卡还款
    public static Observable<String> creditRepayment(String member_id, String withholding_amount, String repayment_card_id) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", member_id);
        params.put("withholding_amount", withholding_amount);
        params.put("repayment_card_id", repayment_card_id);
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_REPAYMENT_WITHHOLD, params, new RequestUtils.TimeOutBuilder(60000, 60000, 60000));
    }

    //添加信用卡还款卡
    public static Observable<String> addCreditCard(int member_id, String card_type_id, String account_name, String card_number) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", member_id);
        params.put("card_type_id", card_type_id);
        params.put("account_name", account_name);
        params.put("card_number", card_number);
        return RequestUtils.postEncryptDecrypt(URLUtil.ADD_CREDIT, params);
    }

    //设置或修改支付密码
    public static Observable<String> setRepayPwd(String member_id, String payment_password) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", member_id);
        params.put("payment_password", payment_password);
        return RequestUtils.postEncryptDecrypt(URLUtil.SET_REPAY_PWD, params);
    }

    //查询支付密码
    public static Observable<String> queryRepayPwd(String member_id) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", member_id);
        return RequestUtils.postEncryptDecrypt(URLUtil.QUERY_REPAY_PWD, params);
    }

    //验证支付密码
    public static Observable<String> verifyRepayPwd(String member_id, String payment_password) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", member_id);
        params.put("payment_password", payment_password);
        return RequestUtils.postEncryptDecrypt(URLUtil.VERIFY_REPAY_PWD, params);
    }

    //解除还款卡绑定
    public static Observable<String> unBoundCredit(String member_id, String credit_card_no) {
        Map<String, Object> params = new HashMap<>();
        params.put("member_id", member_id);
        params.put("credit_card_no", credit_card_no);
        return RequestUtils.postEncryptDecrypt(URLUtil.CREDIT_UNBOUND, params);
    }

}

